package com.zyx.camunda.service.sendtask;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;

/**
 * @author Yaxi.Zhang
 * @since 2022/11/20 09:03
 */
@Slf4j
@Service("sendTask")
public class SendTaskService implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) throws Exception {
        log.info("sendTask发送消息");
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        runtimeService
                // 与接收方 Message 的 name 保持一致
                .createMessageCorrelation("Message_receive_task_test")
                .processInstanceBusinessKey("message_bussinessKey")
                .correlate();
    }
}
